<%@ page import="com.mysql.cj.api.mysqla.result.Resultset" %>
<%@ page import="java.sql.*" %><%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2018/3/31
  Time: 17:07
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<style type="text/css">a{text-decoration: none}</style>
<%
    request.setCharacterEncoding("UTF-8");
    String id=request.getParameter("id");
    Connection connection=null;
    Statement statement=null;
    ResultSet resultset=null;
    try {
        Class.forName("com.mysql.jdbc.Driver");
    }
    catch (ClassNotFoundException e){
        e.printStackTrace();
    }
    try {
        connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/sctu_javaweb_2018?serverTimezone=UTC&characterEncoding=gbk","root","w19971201t");
        statement=connection.createStatement();
        resultset=statement.executeQuery("SELECT * FROM t_user WHERE id='"+id+"'");
       if (resultset.next()) {
            out.write("id:" + id+"</br>"+ "用户名:" + resultset.getString(2) +"</br>"+ "密码:" + resultset.getString(3)+"</br>");
        }
        else
            out.write("此id用户不存在"+"</br>");
        }
    catch (SQLException e){
        e.printStackTrace();
    }
    finally {
        try{
            connection.close();
            statement.close();
        }
        catch(SQLException e){
            e.printStackTrace();
        }
    }
%>
<a href="userList.jsp">返回用户列表</a>
</body>
</html>

